from django_redis import get_redis_connection
class MyRedis:
    def __init__(self):
        self.redis = get_redis_connection(alias="code")
    def set_code(self,phone,code):
        self.redis.setex(phone,60*2,code)
    def get_code(self,phone):
        vel=self.redis.get(phone)
        if vel:
            return vel.decode("utf-8")
        else:
            return None
redistool= MyRedis()